<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <title>登录</title>
    <link rel="stylesheet" type="text/css" href="__CSS__/login_register.css">
</head>
<body>
<div class="topbar-between horizontal-view gradient-color">
    <div class="topbar-back"  onclick="location.href='{:U(\'Index/index\')}'"><div class="topbar-back-icon"></div></div>
    <div class="topbar-title" >登录</div>
    <div class="topbar-right"><a class="topbar-right" href="{:U('Wx/Login/register')}">注册</a></div>
</div>
<div class="round-photo-shadow">
    <img src="__IMG__/pic_dianputubiao@2x.png" style="width: 4rem;height: 4rem;border-radius: 4rem;">
</div>
<div class="input-margin">
    <input id="phone" class="input-border" type="tel" maxlength="11" name="login_name" placeholder="手机号码"/>
</div>
<div class="input-margin">
    <input id="passWord" class="input-border" type="password" name="login_pwd" placeholder="请输入密码"/>
</div>
<div class="forget-btn"><a href="{:U('Login/resetLoginPwd')}">忘记密码？</a></div>
<div class="button-simple gradient-color" onclick="login()">登录</div>
<div class="other-login vertical-view">
    <img style="width: 60px;height: 60px;" src="__IMG__/home_menu_tianpinyinpin@2x.png">
    <div style="line-height: 1rem;height: 1rem;font-size: 0.6rem;color: gray;text-align: center;">微信登录</div>
</div>
<script src="__JS__/jquery2.1.1.min.js"></script>
<script src="__JS__/layer.min.js"></script>
<script>

/**
 * 登录函数
 */
function login(){
    var url="{:U('Wx/Login/loginHandle')}";
    var phone=$.trim($('#phone').val());
    var pwd=$.trim($('#passWord').val());
    var telReg = !!phone.match(/^1[3|7|4|5|8]{1}\d{9}$/);
    if (telReg == false) {
        layer.msg('手机格式不正确');
        return;
    }

    if(!phone||!pwd){
        layer.msg('请输入用户名或者密码');
        return;
    }
    $.ajax({
        type: "POST",
        url: url,
        data: {
            phone:phone,
            pwd:pwd
        },
        dataType: "json",
        success: function(data){
            if(data.status==0){
                layer.msg('登录成功！');
                setTimeout(function(){
                    window.location.href="{:U('Index/index',array('r'=>'my'))}";
                },2000)
            }else if(data.status==-1){
                   layer.msg('用户名或密码错误！');
            }else if(data.status==-2){
                   layer.msg('用户不存在');
            }
        }
    });
}
</script>
</body>
</html>